package com.zzg.service.Impl;

import com.zzg.entity.Menu;
import com.zzg.entity.Price;
import com.zzg.mapper.PriceMapper;
import com.zzg.service.PriceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zzg
 * @version 1.0.0
 * @ClassName：PriceServiceImpl
 * @Description: 描述
 * @date 2021/7/12
 **/
@Service
public class PriceServiceImpl implements PriceService {
    @Autowired
    private PriceMapper priceMapper;


    @Override
    public Map<String, Object> priceList(Integer page, Integer limit) {
        //创建一个map集合
        Map<String, Object> map=new HashMap();
        //得到查询结果
        List<Object> objects = priceMapper.priceList(page, limit);
        //获取查询结果的对象集合
        List<Price>  roleList= (List<Price>) objects.get(0);
        //获取数据总数
        Integer count = ((List<Integer>) objects.get(1)).get(0);
        //添加值
        map.put("code","0");
        map.put("msg","0");
        map.put("count",count);
        map.put("data",roleList);
        return map;
    }

    @Override
    public String priceUpdate(Integer priceId) {
        int flag=priceMapper.priceUpdate(priceId);
        return flag>=0?"成功":"失败";
    }

    @Override
    public Price priceId() {
        return priceMapper.priceId();
    }
}
